/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sharefiles;

import java.io.File;
import services.Command;
import services.Host;
import thread.DiscoveryThreadClient;
import thread.DiscoveryThreadServer;
import thread.FileCheckThread;

/**
 *
 * @author Barbar
 */
public class ShareFiles {

    /**
     * @param args
     * @throws InterruptedException
     */
    public static boolean GUIflag;
    public static boolean closeFlag;
    public static Thread fileCheckThread;

    @SuppressWarnings("deprecation")
    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub

        try {



            Thread GUIThread = new Thread(thread.GUIThread.getInstance());
            GUIThread.start();
            System.out.println("-------------- GUIThread run!--------------");
            Thread discoveryThreadServer = new Thread(DiscoveryThreadServer.getInstance());
            discoveryThreadServer.start();

            System.out.println("--------------Discovery-Client run!--------------" + "\n");


            GUIflag = true;
            while (true) {
                if (fileCheckThread.isAlive()) {
                }

                if ((!GUIflag || !GUIThread.isAlive()) && closeFlag) {
                    System.out.print("FLAAAAAAAAAAAAAAAAAG (SWAG)");
                   discoveryThreadServer.interrupt();
//             discoveryThreadClient.interrupt();


                    System.exit(0);
                }
            }
        } catch (Exception e) {
            System.out.println("::::> ERROR: " + e.toString());
        }

        Thread.sleep(200);

    }
}